﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.controllers.popups {
    import flash.utils.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.views.popups.*;
    import net.wooga.pets.views.popups.payment.*;
    import net.wooga.pets.views.popups.achievement.*;
    import net.wooga.pets.views.components.*;
    import net.wooga.pets.views.popups.missions.*;
    import net.wooga.pets.views.popups.visitfriend.*;
    import net.wooga.pets.views.popups.treatment.*;
    import net.wooga.pets.views.popups.hiredoctor.*;
    import net.wooga.pets.views.popups.fountain.*;
    import net.wooga.pets.views.popups.kiosk.*;
    import net.wooga.pets.views.popups.collection.*;
    import net.wooga.pets.views.popups.goods.*;
    import net.wooga.pets.views.popups.stolengem.*;
    import net.wooga.pets.views.popups.levelup.*;
    import net.wooga.pets.views.popups.energy.*;
    import net.wooga.pets.views.popups.sendgift.*;
    import net.wooga.pets.views.popups.lostpet.*;
    import net.wooga.pets.views.popups.adopt.*;
    import net.wooga.pets.views.popups.credits.*;
    import net.wooga.pets.views.popups.alerts.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;

    public class CreatePopupCommand extends Command {

		[Inject]
        public var event:InfoEvent;
		[Inject]
        public var popupModel:PopupModel;
		[Inject]
        public var ticker:TickModel;

        private static const CLASSES:Dictionary = initClasses();

        override public function execute():void{
            var _local2:IPopupView;
            var _local1:Class = (CLASSES[this.event.id] as Class);
            if (_local1){
                _local2 = new (_local1);
                _local2.data = this.event.info;
                if (((!(this.popupModel.isSending)) || (((this.popupModel.hasOpenPopups) && (_local2.isQueued))))){
                    this.popupModel.addToQueue(_local2);
                } else {
                    if (!this.popupModel.hasOpenPopups){
                        this.ticker.pause = true;
                    };
                    this.popupModel.showPopup(_local2);
                };
            };
        }

        protected static function initClasses():Dictionary{
            var _local1:Dictionary = new Dictionary();
            _local1[GameConstants.ENFORCE_RELOAD_POPUP] = EnforceReloadPopupView;
            _local1[GameConstants.PAYMENT_FAILED_POPUP] = PaymentFailedPopupView;
            _local1[GameConstants.STOLEN_GEM_POPUP] = StolenGemPopupView;
            _local1[GameConstants.NEW_DISEASE_POPUP] = NewDiseasePopupView;
            _local1[GameConstants.FIRST_CURED_POPUP] = FirstCuredPopupView;
            _local1[GameConstants.SHOP_POPUP] = ShopPopupView;
            _local1[GameConstants.LEVEL_UP_POPUP] = LevelUpPopupView;
            _local1[GameConstants.EXTRA_BOOST_POPUP] = ExtraBoostPopupView;
            _local1[GameConstants.ACHIEVEMENT_REWARD_COMPLETED_POPUP] = AchievementReachedPopup;
            _local1[GameConstants.ACHIEVEMENT_BOOK_POPUP] = AchievementBookPopup;
            _local1[GameConstants.ACHIEVEMENT_SHARE_REWARD_POPUP] = AchievementShareRewardPopup;
            _local1[GameConstants.LETTER_POPUP_LAYOUT_A] = LetterPopupTypeA;
            _local1[GameConstants.LETTER_POPUP_LAYOUT_B] = LetterPopupTypeB;
            _local1[GameConstants.LETTER_POPUP_LAYOUT_C] = LetterPopupTypeVersionChanged;
            _local1[GameConstants.GIFT_POPUP] = GiftPopupView;
            _local1[GameConstants.MISSION_TASKS_POPUP] = MissionTasksPopupView;
            _local1[GameConstants.MISSION_REWARD_POPUP] = MissionRewardPopupView;
            _local1[GameConstants.NEXT_ELDER_POPUP] = FountainNextElderPopupView;
            _local1[GameConstants.FOUNTAIN_GEMS_POPUP] = FountainGemsPopupView;
            _local1[GameConstants.FOUNTAIN_RESULT_POPUP] = FountainRewardPopupView;
            _local1[GameConstants.OUT_OF_ENERGY_POPUP] = OutOfEnergyPopupView;
            _local1[GameConstants.VISIT_FRIEND_POPUP] = VisitFriendPopupView;
            _local1[GameConstants.HIRE_DOCTOR_POPUP] = HireDoctorPopupView;
            _local1[GameConstants.KIOSK_POPUP] = KioskPopupView;
            _local1[GameConstants.GOODS_POPUP] = GoodsPopupView;
            _local1[GameConstants.ADOPT_POPUP] = AdoptBabyPopupView;
            _local1[GameConstants.HAPPY_FAMILY_POPUP] = HappyFamilyPopupView;
            _local1[GameConstants.GOT_GIFT_POPUP] = GotGiftPopupView;
            _local1[GameConstants.COLLECTION_POPUP] = CollectionPopupView;
            _local1[GameConstants.COLLECTION_COMPLETE_POPUP] = CollectionCompletedPopupView;
            _local1[GameConstants.LOST_PET_POPUP] = LostPetView;
            _local1[GameConstants.CREDITS_POPUP] = CreditsPopupView;
            return (_local1);
        }

    }
}//package net.wooga.pets.controllers.popups 
